/**
 * Created by Administrator on 2015/12/23 0023.
 */

var express = require('express');
var router = express.Router();
var request = require('request');


router.get('/:id3', function(req, res, next) {
    global.id3 = req.params.id3;
    var reqUrl ="http://10.32.18.68:8000/host-info/?vcenter="+global.id1+"&vm="+global.id3+"";
    request({uri:reqUrl},function(error, response, body){
            if(response.statusCode == 200){
                console.log('success! body:'+body);
                var str = JSON.parse(body);
                console.log('vm-info:'+str);
                res.render('vm',{
                    title:'VM',
                    msg:str
                });
            }else{
                console.log('error res:'+response);
                res.send('error!');
            }
        }
    );
});

module.exports = router;



